package com.rockcent.mall.lib.repository;

import com.rockcent.common.common.PageResult;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MallMember;
import com.rockcent.mall.lib.domain.enumclass.MallMemberStatus;
import com.rockcent.mall.lib.dto.MallMemberDto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;
import java.util.List;

/**
 * Created by zhangjh on 2017/3/8.
 */
@Repository
public interface MallMemberRepository extends JpaRepository<MallMember, Long>, JpaSpecificationExecutor, MallMemberRepositoryCustom {
    MallMember findByMallIdAndIsDelete(Long id, Whether no);


    @Lock(LockModeType.PESSIMISTIC_WRITE)
    MallMember findOne(Long mallMemberId);

    List<MallMember> findByStatusAndIsDelete(MallMemberStatus status, Whether no);

    MallMember findTop1ByMallId(Long mallId);

    MallMember findTop1ByMallIdOrderByLastUpdatedDesc(Long mallId);


    MallMember findById(Long mallMemberId);
}
